package com.questionGenerator.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.questionGenerator.dto.req.PaperCombinationReqDTO;
import com.questionGenerator.dto.req.PaperListReqDTO;
import com.questionGenerator.dto.resp.PaperRespDTO;
import com.questionGenerator.service.PaperService;
import com.questionGenerator.vo.UnifyResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: usagi
 * @Date: 2024/04/25/17:45
 * @Description:
 */
@RestController
@RequestMapping("/paper/")
public class PaperController {
    @Autowired
    PaperService paperService;
    @PostMapping("combination")
    public UnifyResponseVO<Boolean> paperCombination(@RequestBody PaperCombinationReqDTO paperCombinationReqDTO){
            return new UnifyResponseVO("200",paperService.paperCombination(paperCombinationReqDTO));
    }

    @GetMapping("paperList")
    public UnifyResponseVO<IPage<PaperRespDTO>> getPaperListByUserId(PaperListReqDTO paperListReqDTO){
        return new UnifyResponseVO("200",paperService.getPaperListByUserId(paperListReqDTO));
    }
    @GetMapping("download/{fileName}")
    public UnifyResponseVO<String> downloadPaper(HttpServletResponse httpServletResponse, @PathVariable String fileName){
            return new UnifyResponseVO("200",paperService.downloadPaper(httpServletResponse,fileName));
    }
}
